java无法查找JNDI
我的ejb-jar.xml
中有以下声明
<enterprise-beans>
<entity>
<description>Simple CMP Entity bean example</description>
<ejb-name>CalculatorBean</ejb-name>
<remote>ejb3.stateless.CalculatorRemote</remote>
<ejb-class>ejb3.stateless.CalculatorBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>false</reentrant>
</entity>
</enterprise-beans>
我试图从我的servlet中进行如下查找:
CalculatorRemote calculator = (CalculatorRemote)ic.lookup("java/comp/env/:CalculatorBean");
但是它说找不到指定的名称
我已经为CalculatorRemote
和CalculatorBean
创建了类
这里是CalculatorRemote
@Remote
public interface CalculatorRemote {
public float add(float x, float y);
public float subtract(float x, float y);
public float multiply(float x, float y);
public float division(float x, float y);
}
CalculatorBean
是CalculatorRemote
的一个实现。ic是上下文的缩写
# 1 楼答案
试着用这种方法来查找Bean
编辑:
对于玻璃鱼,无需添加 移除
java:comp/env/
部分